Imports TuitcAutoInfo.BLL

Public Class ArticleView
    Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub
    Protected WithEvents plhImage As System.Web.UI.WebControls.PlaceHolder
    Protected WithEvents litContent As System.Web.UI.WebControls.Literal
    Protected WithEvents lblHeadline As System.Web.UI.WebControls.Label
    Protected WithEvents hypDownload As System.Web.UI.WebControls.HyperLink
    Protected WithEvents dgQuickLinks As System.Web.UI.WebControls.DataGrid

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Dim ArticleID As Integer

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'If IsNothing(Session("CurrentUser")) Then
        '    Response.Redirect("Userlogin.aspx?ReturnUrl=Home.aspx")
        'End If

        ArticleID = Request.QueryString("Articleid")
        If Not Page.IsPostBack AndAlso ArticleID > 0 Then
            BindContent()
        End If
    End Sub

    Private Sub BindContent()
        Dim objArticle As New BLL.Article(ArticleID, True)

        '// Text
        lblHeadline.Text = objArticle.Headline
        litContent.Text = objArticle.Detail

        With hypDownload
            '    If objArticle.FileName > String.Empty Then
            '        .Visible = True
            '        .NavigateUrl = System.Configuration.ConfigurationSettings.AppSettings("SiteURL") _
            '                     & "/UploadedFiles/" & objArticle.FileName
            '    Else
            .Visible = False
            '    End If
        End With

        '// Images
        FillImages(New ArticleImageCollection(ArticleID))              '// Fill in all the images associated with this item

    End Sub

    Private Sub FillImages(ByVal objArticleImages As ArticleImageCollection)
        Dim objImage As ArticleImage
        Dim tr As TableRow
        Dim td As TableCell
        Dim img As CMSCore.RWControls.RWResizedImage
        Dim tblImages As New WebControls.Table

        For Each objImage In objArticleImages
            tr = New TableRow
            td = New TableCell
            'td.Attributes.Add("style", "padding:5px;")
            td.Attributes.Add("style", "PADDING-BOTTOM:5px;")

            img = New CMSCore.RWControls.RWResizedImage
            img.Width = New System.Web.UI.WebControls.Unit("174px")
            img.MaxHeight = New System.Web.UI.WebControls.Unit("500px")
            img.ThumbnailDirURL = "~/UploadedFiles/"
            img.ImageUrl = "~/UploadedFiles/" & objImage.ImageFile

            td.Controls.Add(img)
            tr.Cells.Add(td)
            tblImages.Rows.Add(tr)
        Next
        plhImage.Controls.Add(tblImages)
    End Sub


    Private Sub bindListQuickLinks()
        Dim objHom As New HomePageLink
        dgQuickLinks.DataSource = objHom.SelectAll
        dgQuickLinks.DataBind()
    End Sub

End Class
